import org.bigcrunch.processing.libcv.*;
import toxi.video.capture.*;
import JMyron.*;

String CAPTURE_DEVICE = "vfw:Microsoft WDM Image Capture (Win32):0";
int CAPTURE_WIDTH = 160;
int CAPTURE_HEIGHT = 120;

SimpleCapture capture;
LibCVExt libcv;

void setup() {
  size(320,240);
  capture = new JMyronCapture();
  //capture = new JMFSimpleCapture();
  if (!capture.initVideo(CAPTURE_DEVICE, CAPTURE_WIDTH, CAPTURE_HEIGHT, 0)) {
    println(capture.getError());
    // you might have to (re-)run the JMFRegistry application
    // devices sometimes are unrecognized
    System.exit(0);
  }
 libcv = new LibCVExt(this, capture);
 libcv.setGrid(10);
 libcv.setDebug(true);
}

void draw() {
    //delta buffer is already computed in pre()
    //libcv.processFrame(libcv.getFrame());
    //m.update();
    PImage dbuf=libcv.getDeltaBuffer();
    copy(dbuf,0,0,dbuf.width,dbuf.height,0,0,width,height);
}
void processRegionEvent(Region r){
  println(r);
}
